<template>
  <div>
    <!-- 推荐歌单 -->
    <div class="commendBox">
      <h3><span>|</span> 推荐歌单</h3>
      <ul class="commendList" v-for="(item, index) in commendList" :key="index">
        <li @click="goSongListDetails(item.id)">
          <div class="commendImgBox">
            <span class="giveCall">{{ item.trackCount }}万</span>
            <img :src="item.picUrl" alt="" />
          </div>
          <div class="commendtitle">
            <p>{{ item.name }}</p>
          </div>
        </li>
      </ul>
    </div>
  </div>
</template>
<script>
import { commend } from "../api/api";

export default {
  name: "commend",
  data() {
    return {
      commendList: "",
      
    };
  },
  created() {
    commend().then((res) => {
      console.log(res);
      this.commendList = res.result;
    });
  },
  methods: {
   
    // 去歌单详情
    goSongListDetails(id) {
      console.log(2434);
      this.$router.push({
        path: "/songDetails",
        query: { id },
      });
    },
  },
};
</script>
<style scoped lang="less">
// 推荐音乐
.commendBox > h3 > span {
  color: red;
  font-weight: 800;
}
.commendList {
  //   overflow: hidden;
  margin: auto;
  width: 96%;
  // display: flex;
  // justify-content: center;
  // justify-content: space-around;
  flex-wrap: wrap;
}
.commendList > li {
  margin: auto;
  float: left;
  width: 32.9%;
  height: 200px;
  // text-align: center;
}
.commendImgBox {
  position: relative;
  width: 100%;
  height: 120px;
  // background-color: aqua;
  border: 2px solid #fff;
  border-bottom: none;
  border-top: none;
}
.commendImgBox > img {
  width: 100%;
  height: 100%;
}
.giveCall {
  position: absolute;
  top: 0;
  right: 2px;
  color: #fff;
  font-size: 12px;
}
.commendtitle {
  padding: 0 4px;
}

.commendtitle > p {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  font-size: 14px;
}
// 最新音乐
.newestBox {
  width: 100%;
}
.newestBox > h3 > span {
  color: red;
  font-weight: 800;
}
.newestList {
  width: 100%;
  margin: auto;
  overflow: hidden;
}
.newestList > li {
  margin: auto;
  overflow: hidden;
  position: relative;
  width: 94%;
  height: 42px;
  // line-height: 60px;
  border-bottom: 1px solid #ddd;
  padding: 8px 1px;
}

.footerBox {
  width: 100%;
  height: 200px;
}
.spanTitle {
  font-size: 18px;
}
.spanAuthor {
  display: block;
  font-size: 14px;
  color: #999;
}
.newestLeft {
  float: left;
}
.newestLeft > span > :first-child {
  font-size: 28px;
  color: red;
}
.newestRight {
  float: right;
  position: absolute;
  top: 28%;
  right: 5px;
  width: 28px;
  height: 28px;
  // background-color: aqua;
}
</style>
